package top.zuli.package01.class15;

import org.junit.Test;

public class Demo5 {
    @Test
    public void StringMethodTest5() {
        String str = "胖叔讲java";
        //返回字符串长度
        System.out.println(str.length());
        //返回某索引处的字符
        System.out.println(str.charAt(2));
        //判断字符串是否为空
        System.out.println(str.isEmpty());
        //去掉字符的前后空格
        System.out.println("  胖叔讲  java   ".trim());
        //判断字符串是否匹配正则表达式  .+ 表示任意字符出现一次以上
        System.out.println(str.matches(".+"));
        //按照正则表达式分组
        String str2 = "窗前明月光，疑是地上霜，举头望明月，低头思故乡";
        //按照中文逗号分组,分三组
        String[] strs = str2.split("，",3);
        for(String s : strs){
            System.out.println(s);
        }
    }
}

/*
public class Demo5 {
    @Test
    public void StringMethodTest5() {
        String str = "胖叔讲java";
        System.out.println(str.length());
        System.out.println(str.charAt(2));
        System.out.println(str.isEmpty());
        System.out.println("  胖叔讲  java   ".trim());
        System.out.println(str.matches(".+"));
        String str2 = "窗前明月光，疑是地上霜，举头望明月，低头思故乡";
        String[] strs = str2.split("，",3);
        for(String s : strs){
            System.out.println(s);
        }
    }
}
*/

/*
public class Demo5 {
    @Test
    public void StringMethodTest5() {
        String str = "胖叔讲java";
        System.out.println(str.length());
        System.out.println(str.charAt(2));
        System.out.println(str.isEmpty());
        System.out.println("  胖叔讲  java   ".trim());
        System.out.println(str.matches(".+"));
        String str2 = "窗前明月光，疑是地上霜，举头望明月，低头思故乡";
        String[] strs = str2.split("，",3);
        for(String s : strs){
            System.out.println(s);
        }
    }
}
*/
